﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace HYElectricSetting
{
	public partial class CreateSingleItemForm : System.Windows.Forms.Form
	{
		public string NewValue { get; set; }

		public CreateSingleItemForm(string title, string value, List<string> keys)
		{
			this.InitializeComponent();
			this.formTitle = title;
			this.defaultValue = value;
			this.NewValue = value;
			this.keySet = keys;
		}

		private void CreateSingleItemForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.Text = this.formTitle;
			this.txtName.IsNumber = InputSelection.number;
			this.txtName.IsPositive = SymbolSelect.positive;
			this.txtName.IsInt = NumberType.integer;
			this.txtName.Text = this.defaultValue;
			this.txtName.Focus();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.NewValue = StringTools.RemoveZero(this.txtName.Text.Trim());
			bool flag = string.IsNullOrEmpty(this.NewValue);
			if (flag)
			{
				TaskDialog.Show("盈建科提示", "管径的值不能为空。");
				this.txtName.Focus();
			}
			else
			{
				bool flag2 = this.NewValue != this.defaultValue && this.keySet.Contains(this.NewValue);
				if (flag2)
				{
					TaskDialog.Show("盈建科提示", "此管径已存在。请指定唯一管径值。");
					this.txtName.Focus();
				}
				else
				{
					base.DialogResult = DialogResult.OK;
				}
			}
		}

		private string formTitle;

		private string defaultValue;

		private List<string> keySet;
	}
}
